package cn.lyjuan.android.demofive.ui.component.recyclerview;

import android.os.Bundle;
import android.support.annotation.Nullable;

import java.util.ArrayList;
import java.util.List;

import cn.lyjuan.android.demofive.R;
import cn.lyjuan.android.mylibrary.frame.BaseActivity;
import cn.lyjuan.android.mylibrary.view.recycler.DividerItemDecoration;
import cn.lyjuan.android.mylibrary.view.recycler.RecyclerListView;

/**
 * Created by chad on 06/11/2017.
 */

public class RecyclerListActivity extends BaseActivity
{
    /**
     * 水平列表
     */
    private RecyclerListView recyclerView;

    /**
     * 垂直列表
     */
    private RecyclerListView recyclerVerticalView;

    private List<String> list;

    private RecyclerListAdapter adp;
    private RecyclerListAdapter adpVertical;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.ui_component_recycler_list);
    }

    @Override
    protected void loadView()
    {
        recyclerView = (RecyclerListView) findViewById(R.id.recycler_list);
        recyclerVerticalView = (RecyclerListView) findViewById(R.id.recycler_list_vertical);
    }

    @Override
    protected void setView()
    {
        list = new ArrayList<>();

        adp = new RecyclerListAdapter(list, R.layout.ui_component_recycler_list_item);
        recyclerView.addItemDecoration(new DividerItemDecoration());
        recyclerView.setAdapter(adp);

        adpVertical = new RecyclerListAdapter(list, R.layout.ui_component_recycler_vertical_list_item);
        recyclerVerticalView.addItemDecoration(new DividerItemDecoration());
        recyclerVerticalView.setAdapter(adpVertical);
    }

    @Override
    protected void bindListener()
    {

    }

    @Override
    protected void loadData()
    {
        for (int i = 0; i < 100; i++)
        {
            list.add("String-" + i);
        }

        adp.notifyDataSetChanged();
    }
}
